#include "Frm05.h"

Frm05::Frm05(HmiApp* app, STTWidget *par, const string& id, const string& desc) : STTPage(app->getRuntime(), par, id, desc) {
	hmiApp = app;
}

Frm05::~Frm05() {
}

void Frm05::onInit() {

}

void Frm05::createParts() {
	setMainArg(0, 0, 1024, 600);
	setMainStyle(0, 0xffffff, 0xffffff, 0, 255, 0, 0xc0c0c0);

	/*----------------------------- Image : wMImage1                     -----------------------------*/
	wMImage1 = new STTImage(p_rt, this, "wMImage1");
	wMImage1->setMainArg(241, 0, 96, 96);
	wMImage1->addStateImg("0", "./images/img17369918959962_96X96R0.png");

	/*----------------------------- Button : wMButton2                   -----------------------------*/
	wMButton2 = new STTButton(p_rt, this, "wMButton2", 0);
	wMButton2->setMainArg(393, 1, 126, 61, false);
	wMButton2->setPressedArg("启动动画", 0x0, "文泉驿微米黑", 16, 0);
	wMButton2->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton2->setReleasedArg("启动动画", 0x0, "文泉驿微米黑", 16, 0);
	wMButton2->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton2->onEventHandler(Event::CLICKED, this, (EHandler) & Frm05::wMButton2_clk_cb);

	/*----------------------------- Button : wMButton3                   -----------------------------*/
	wMButton3 = new STTButton(p_rt, this, "wMButton3", 0);
	wMButton3->setMainArg(1, 1, 98, 48, false);
	wMButton3->setPressedArg("返回主页", 0x0, "文泉驿微米黑", 16, 0);
	wMButton3->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton3->setReleasedArg("返回主页", 0x0, "文泉驿微米黑", 16, 0);
	wMButton3->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton3->bindOpenFormHandler(Event::CLICKED, "Frm03", PageMode::NEWWIN, NULL);

	/*----------------------------- Button : wMButton4                   -----------------------------*/
	wMButton4 = new STTButton(p_rt, this, "wMButton4", 0);
	wMButton4->setMainArg(528, 1, 126, 61, false);
	wMButton4->setPressedArg("停止动画", 0x0, "文泉驿微米黑", 16, 0);
	wMButton4->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton4->setReleasedArg("停止动画", 0x0, "文泉驿微米黑", 16, 0);
	wMButton4->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton4->onEventHandler(Event::CLICKED, this, (EHandler) & Frm05::wMButton4_clk_cb);

	/*called after widget created.*/

	return; //createParts END
}

static void valuecb(void* obj, int32_t v) {
	STTImage* widget = (STTImage*)obj;
	widget->setZoom(v*1.0/256);
}

void Frm05::onLoad() {

}

bool Frm05::onClosing() {
	return true;
}

void Frm05::onDispose() {

}

void Frm05::wMButton2_clk_cb(uint16_t code, LvEvent e) {
	/*wMButton2（Frm03）的点击事件*/
	wMImage1->getStyle()->p_anim->doAnim(wMImage1,200,256,500,valuecb,NULL,-1,100,500,3);
}

void Frm05::wMButton4_clk_cb(uint16_t code, LvEvent e) {
	/*wMButton2（Frm03）的点击事件*/
	wMImage1->getStyle()->p_anim->stopAnim(wMImage1);
}
